/**
//输入一个链表的头节点，从尾到头反过来返回每个节点的值（用数组返回）。 
//
// 
//
// 示例 1： 
//
// 输入：head = [1,3,2]
//输出：[2,3,1] 
//
// 
//
// 限制： 
//
// 0 <= 链表长度 <= 10000 
// Related Topics 栈 递归 链表 双指针 👍 186 👎 0

*/

package com.xixi.easy;

import com.xixi.dataStructure.lineList.ListNode;

public class ID_Offer_06_CongWeiDaoTouDaYinLianBiaoLcof {
public static void main(String[] args) {
Solution solution = new ID_Offer_06_CongWeiDaoTouDaYinLianBiaoLcof().new Solution();
}


//leetcode submit region begin(Prohibit modification and deletion)
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    int depth = 0;//数组深度
    int[] resultInt;
    int index = 0;
    public int[] reversePrint(ListNode head) {
        if(head == null ) return new int[depth];
        ++ depth;
        if(head.next == null){
            resultInt = new int[depth];
            index = depth;
            resultInt[depth - index] = head.val;
            return resultInt;
        }
        resultInt = reversePrint(head.next);
        --index;
        resultInt[depth - index] = head.val;
        return resultInt;
    }
}
//leetcode submit region end(Prohibit modification and deletion)




}